﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityModels;
using System.Data.Entity;

namespace BusinessLayer
{
    public class Controller
    {

        private static Controller instance;
        public static Controller Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new Controller();
                }
                return instance;
            }
        }

        private UserControl userControl;
        private EventControl eventControl;

        private Controller()
        {
            userControl = new UserControl();
            eventControl = new EventControl();
        }

               
        public bool RegisterUser(User us)
        {
           return userControl.RegisterUser(us);                
        }

        public bool LogIn(User us)
        {
            return userControl.LogIn(us);
        }

        public bool UpdateUser(User user)
        {
            return userControl.Update(user);
        }

        public User GetUser(String username)
        {
            return userControl.GetUser(username);
        }

        public User GetUser(User us)
        {
            return userControl.GetUser(us.username);
        }

        public User GetUser(int id)
        {
            return userControl.GetUser(id);
        }

        public List<User> GetUsers(Event ev, Byte b)
        {
            return userControl.GetUsers(ev, b);
        }

        
        public bool UserExists(User us) 
        {
            return userControl.UserExists(us);
        }



        public bool CreateEvent(Event ev, List<Location> locations, List<DateTime> dates, List<TimeSpan> times)
        {
            return eventControl.CreateEvent(ev,locations,dates,times);
         }


        public bool UpdateEvent(Event ev, List<Location> locations, List<DateOptions> dates, List<TimeOptions> times)
        {
            return eventControl.UpdateEvent(ev, locations, dates, times);   
            
        }

        public bool DeleteEvent(Event ev)
        {
            return eventControl.DeleteEvent(ev);

        }


        public Event GetEvent(int id)
        {
            return eventControl.GetEvent(id);
        }

        public Event GetEvent(Event ev)
        {
            return eventControl.GetEvent(ev.idevent);
        }

        public List<Event> GetEvents(User us, Byte b)
        {
            return  eventControl.GetEvents(us,b);
        }


        public bool EventExists(Event ev)
        {
            return eventControl.EventExists(ev);
        }

        public bool LocationVoted(User us, Event ev) {
            return eventControl.LocationVoted(us,ev);
        
        }
        public bool DateVoted(User us, Event ev)
        {
            return eventControl.DateVoted(us, ev);

        }
        public bool TimeVoted(User us, Event ev)
        {
            return eventControl.TimeVoted(us, ev);

        }
        public bool VoteLocation(User us, Event ev, Location lo)
        {
            return eventControl.VoteLocation(us, ev, lo);

        }
        public bool VoteDate(User us, Event ev, DateTime d)
        {
            return eventControl.VoteDate(us, ev, d);

        }

        public bool VoteTime(User us, Event ev, TimeSpan t)
        {
            return eventControl.VoteTime(us, ev, t);

        }
        public bool VotingFinished(Event ev)
        {

            return eventControl.VotingFinished(ev);
        }
        public Location GetLocationVoted(Event ev)
        {

            return eventControl.GetLocationVoted(ev);
        }
        public TimeSpan GetTimeVoted(Event ev)
        {

            return eventControl.GetTimeVoted(ev);
        }
        public DateTime GetDateVoted(Event ev)
        {

            return eventControl.GetDateVoted(ev);
        }

        public bool Attend(User us, Event ev) {
            return eventControl.Attend(us, ev);
        }
        public bool Attending(User us, Event ev)
        {
            return eventControl.Attending(us, ev);
        }
        public bool NotAttend(User us, Event ev)
        {
            return eventControl.NotAttend(us, ev);
        }

        public bool Invite(User us, Event ev)
        {
            return eventControl.Invite(us, ev);
        }

        public List<Location> getLocations(Event ev)
        {
            return eventControl.getLocations(ev);

        }
        public List<DateOptions> getDates(Event ev)
        {
            return eventControl.getDates(ev);

        }
        public List<TimeOptions> getTimes(Event ev)
        {
            return eventControl.getTimes(ev);

        }
    }
}
